package com.sailing.xjpb.elasticsearch.repository;

import co.elastic.clients.elasticsearch.core.SearchRequest;
import org.springframework.data.domain.Pageable;

/**
 * 分页参数构建器
 *
 * @author YaoWei
 * createDate: 2022-12-29
 */
public class PageRequestBuilder extends SearchRequest.Builder {
    /**
     * 分页参数
     */
    private Pageable pageable;

    public PageRequestBuilder pageable(Pageable pageable) {
        this.pageable = pageable;
        from((int) pageable.getOffset()).size(pageable.getPageSize());
        // TODO 未加Sort排序
        return this;
    }

    public Pageable getPageable() {
        return this.pageable;
    }
}
